<?php
$this->_var['ujs'][] = $this->_var['TMPL_REAL']."/js/u.js";
$this->_var['cujs'][] = $this->_var['TMPL_REAL']."/js/u.js";
?>
<script type="text/javascript" src="{function name="parse_script" v="$ujs" c="$cujs"}"></script>
<div class="inc wb">
	<div class="inc_main">		
		<div class="list_title clearfix">
        	<div {if $ACTION_NAME eq 'index'}class="cur"{/if}>
				<a href="{url x="index" r="agency_money#index"}">{$LANG.UC_LOGS}</a>
			</div>
			<div {if $ACTION_NAME eq 'incharge'}class="cur"{/if}>
				<a href="{url x="index" r="agency_money#incharge"}">{$LANG.UC_MONEY_INCHARGE}</a>
			</div>
			<div {if $ACTION_NAME eq 'incharge_log'}class="cur"{/if}>
				<a href="{url x="index" r="agency_money#incharge_log"}">{$LANG.UC_MONEY_INCHARGE_LOG}</a>
			</div>
			<div {if $ACTION_NAME eq 'bank'}class="cur"{/if}>
				<a href="{url x="index" value="agency_money#bank"}">{$LANG.UC_CARRY}</a>
			</div>
			<div {if $ACTION_NAME eq 'carry_log'}class="cur"{/if}>
				<a href="{url x="index" value="agency_money#carry_log"}">提现日志</a>
			</div>
		</div>
		<div class="uc_r_bl_box p10">
			<div class="cf p15">
				<label><input type="radio" name="carry_type"  value="1" checked="checked"/> 第三方资金提现</label>
			</div>
			<style type="text/css">
				.uc_r_bl_box .field label{ color:#666; width:180px; }
				.cashdraw_tips {position:absolute; z-index:99999; }
				.cashdraw_tips .cashdraw_tip_header { background: url("{$TMPL}/images/reg_tip_header_t.gif") no-repeat scroll 0 17px transparent; float: left; height: 47px; position: relative; width: 6px; z-index: 1000; }
				.cashdraw_tips .cashdraw_tip_body_container { background: url("{$TMPL}/images/reg_tip_bg_bottom.gif") repeat-x scroll center bottom transparent; float: left; margin-left: -1px; padding-bottom: 2px; position: relative; }
				.cashdraw_tips .cashdraw_tip_body { background: none repeat scroll 0 0 #FFFFFF; border: 1px solid #BBBBBB; float: left; }
				.cashdraw_tips .cashdraw_tip_body .cashdraw_tip_content { color: #666666; display: block; padding: 5px 9px 4px; width:291px; line-height:20px;}
				.tiptable { background:#ccc}
				.tiptable tr.bg td{ background:#fff; padding: 0 5px;text-align:center;}
			</style>
			<div class="cf uc_r_bl_box hide p15 pr" id="IPS_CARRY">
				<form id="IPS_CARRY_FORM" name="IPS_CARRY_FORM">
					<div class="field">
		                <label>可用资金：</label>
		                <span class="J_u_money_0 f_red"></span>
						<input id="Jcarry_totalAmount" type="hidden" value="0" />
		            </div>
					<div class="field">
		                <label><span class="f_red b">*</span> 提取金额：</label>
		                <span><input type="text" autocomplete="off" name="amount" class="f-input" id="Jcarry_amount">&nbsp;&nbsp;元</span>
		                &nbsp;
						<span id="Jcarry_balance" class="f_red lh28"></span>
		            </div>
		            <div class="field">
		                <label>提现费用：</label>
		                <span id="Jcarry_fee">0.00 元</span>
						{if $fee_config}
						<img src="{$TMPL}/images/tips_wh.jpg" id="imgtips" style="position:relative;top:3px;left:15px;z-index:999; cursor:pointer;" onmouseover="tips(this,'第三方收取提现手续费:&lt;/br&gt;&lt;table width=\'100%\' class=\'tiptable\' cellspacing=\'1\' border=\'0\' &gt;&lt;tr style=\'background:#eff5fe;text-align:center\'&gt;{foreach from="$fee_config" item="fee"}&lt;td height=\'22\'&gt;{$fee.name}&lt;/td&gt;{/foreach}&lt;/tr&gt;&lt;tr class=\'bg\'&gt;{foreach from="$fee_config" item="fee"}&lt;td&gt;{$fee.fee_format}&lt;/td&gt;{/foreach}&lt;/tr&gt;&lt;/table&gt;',70,290)"><br>
		            	{/if}
					</div>
		            <div class="field">
		                <label>实付金额：</label>
		                <span id="Jcarry_realAmount">0.00 元</span><br>
		            </div>
		            <div class="field">
		                <label>提现后账户可用余额：</label>
		                <span id="Jcarry_acount_balance">0.00 元</span>
		                <br>
		            </div>
					<div class="f_red tc" style="font-size:14px;">警告：禁止信用卡套现、虚假交易等行为，一经确认，将终止该账户的使用。</div>
					<div class="blank20"></div>
					<div class="tc">
						<input type="hidden" name="acount_balance" id="Jcarry_acount_balance_res" style="width:70px">
			            <input type="submit" value="申请提现" class="sub_btn">
			        </div>
				</form>
			</div>
		</div>
	</div>
</div>
<div class="blank"></div>	
<script type="text/javascript" src="{$APP_ROOT}/public/runtime/app/region.js"></script>	
<script type="text/javascript" src="{$TMPL}/js/jquery.bank.js"></script>	
<script type="text/javascript">
	var json_fee = {$json_fee};
	$("#IPS_CARRY").removeClass("hide");
	
	jQuery(function(){
			
			checkIpsBalance(1,{$manageagency_info.id},function(result){
				if(result.pErrCode=="0000"){
					$(".J_u_money_0").html(result.pBalance);
					$("#Jcarry_totalAmount").val(result.pBalance);
				}
			});
			
			
			
			$("#IPS_CARRY_FORM").submit(function(){
				if($.trim($("#Jcarry_amount").val())=="" || !$.checkNumber($("#Jcarry_amount").val()) || parseFloat($("#Jcarry_amount").val())<=0){
					$.showErr(LANG.CARRY_MONEY_NOT_TRUE,function(){
						$("#Jcarry_amount").focus();
					});
					return false;
				}
				if(parseFloat($("#Jcarry_acount_balance_res").val())<0){
					$.showErr(LANG.CARRY_MONEY_NOT_ENOUGHT,function(){
						$("#Jcarry_acount_balance_res").focus();
					});
					return false;
				}
				
				window.location.href= APP_ROOT + "/index.php?ctl=collocation&act=DoDwTrade&user_type=1&user_id={$manageagency_info.id}&pTrdAmt="+$.trim($("#Jcarry_amount").val());
				return false;
			});
		
		
		
		$("select[name='region_lv1']").live("change",function(){
			load_select("1");
		}).live('click', function () {
                if ($.data(this, 'events') == null || $.data(this, 'events').change == undefined){
                    $(this).bind('change', function () {
                       load_select("1");
                    });
                }
		});
		$("select[name='region_lv2']").live("change",function(){
			load_select("2");
		}).live('click', function () {
                if ($.data(this, 'events') == null || $.data(this, 'events').change == undefined){
                    $(this).bind('change', function () {
                       load_select("2");
                    });
                }
		});
		$("select[name='region_lv3']").live("change",function(){
			load_select("3");
		}).live('click', function () {
                if ($.data(this, 'events') == null || $.data(this, 'events').change == undefined){
                    $(this).bind('change', function () {
                       load_select("3");
                    });
                }
		});	
		
		
		$("#Jbank_bank_id").live("change",function(){
			if($(this).val()=="other"){
				$("#Jbank_otherbank").removeClass("hide");
			}
			else{
				$("#Jbank_otherbank").addClass("hide");
			}
		}).live('click', function () {
                if ($.data(this, 'events') == null || $.data(this, 'events').change == undefined){
                    $(this).bind('change', function () {
                       if($(this).val()=="other"){
							$("#Jbank_otherbank").removeClass("hide");
						}
						else{
							$("#Jbank_otherbank").addClass("hide");
						}
                    });
                }
		});
		
		$("#addbank-box .reset_btn").live("click",function(){
			$.weeboxs.close("addbank-box");
		});
		
		$("#addbank-box .sub_btn").live("click",function(){
			
			if($("#Jbank_real_name").val()==""){
				$.showErr("请输入开户名",function(){
					$("#Jbank_real_name").focus();
				});
				return false;
			}
			if($("#Jbank_bank_id").val()==""){
				$.showErr(LANG.PLASE_ENTER_CARRY_BANK,function(){
					$("#Jbank_bank_id").focus();
				});
				return false;
			}
			if($("#Jbank_bank_id").val()=="other" && $("#Jbank_otherbank").val()==""){
				$.showErr(LANG.PLASE_ENTER_CARRY_BANK,function(){
					$("#Jbank_bank_id").focus();
				});
				return false;
			}
			
			if($("#Jbank_region_lv3").val()=="" || $("#Jbank_region_lv3").val()=="0"){
				$.showErr("请选择开户行所在地",function(){
					$("#Jbank_region_lv3").focus();
				});
				return false;
			}
			
			if($("#Jbank_bankzone").val()==""){
				$.showErr("请输入开户行网点",function(){
					$("#Jbank_bankzone").focus();
				});
				return false;
			}
			
			if($.trim($("#Jbank_bankcard").val())==""){
				$.showErr(LANG.PLASE_ENTER_CARRY_BANK_CODE,function(){
					$("#Jbank_bankcard").focus();
				});
				return false;
			}
			if($.trim($("#Jbank_rebankcard").val())==""){
				$.showErr(LANG.PLASE_ENTER_CARRY_CFR_BANK_CODE,function(){
					$("#Jbank_rebankcard").focus();
				});
				return false;
			}
			if($.trim($("#Jbank_bankcard").val())!=$.trim($("#Jbank_rebankcard").val())){
				$.showErr(LANG.TWO_ENTER_CARRY_BANK_CODE_ERROR,function(){
					$("#Jbank_rebankcard").focus();
				});
				return false;
			}
			
			
			var query = $("#Jbank_From").serialize();
			var ajaxurl = $("#Jbank_From").attr("action");
			$.ajax({
				url:ajaxurl,
				data:query,
				type:"post",
				dataType:"json",
				success:function(result){
					if(result.status==1){
						$.showSuccess(result.info,function(){
							window.location.reload();
						});
					}
					else{
						$.showErr(result.info);
					}
				},
				error:function(){
					$.showErr("发生错误");
				}
			});
		});
	});
	
		
	function load_select(lv)
	{
		var name = "region_lv"+lv;
		var next_name = "region_lv"+(parseInt(lv)+1);
		var id = $("select[name='"+name+"']").val();
		
		if(lv==1)
		var evalStr="regionConf.r"+id+".c";
		if(lv==2)
		var evalStr="regionConf.r"+$("select[name='region_lv1']").val()+".c.r"+id+".c";
		if(lv==3)
		var evalStr="regionConf.r"+$("select[name='region_lv1']").val()+".c.r"+$("select[name='region_lv2']").val()+".c.r"+id+".c";
		
		if(id==0)
		{
			var html = "<option value='0'>="+LANG['SELECT_PLEASE']+"=</option>";
		}
		else
		{
			var regionConfs=eval(evalStr);
			evalStr+=".";
			var html = "<option value='0'>="+LANG['SELECT_PLEASE']+"=</option>";
			for(var key in regionConfs)
			{
				html+="<option value='"+eval(evalStr+key+".i")+"'>"+eval(evalStr+key+".n")+"</option>";
			}
		}
		$("select[name='"+next_name+"']").html(html);
		
		if(lv != 4)
		{
			load_select(parseInt(lv)+1);
		}
		
		
	}
	

</script>